#include "weathernum.h"


void WeatherNum::setTodayWeatherCode(weatherTpye todayWeatherCode)
{
  this->_todayWeatherCode = todayWeatherCode;
}

void WeatherNum::setCurrentWeatherCode(weatherTpye currentWeatherCode)
{
  this->_currentWeatherCode = currentWeatherCode;
}

void WeatherNum::setTodayWeatherAndCurrentWeatherCode(weatherTpye todayWeatherCode, weatherTpye currentWeatherCode)
{
  // this->_todayWeatherCode = todayWeatherCode;
  // this->_currentWeatherCode = currentWeatherCode;
  this->setTodayWeatherCode(todayWeatherCode);
  this->setCurrentWeatherCode(currentWeatherCode);
}


/* 设置天气图标
 *
 * @param **weatherCode
 * @param *weatherSize
 * @param mode 0,今日天气  1,实时天气
 */
void WeatherNum::setWeather(const uint8_t **weatherCode, uint32_t *weatherSize, uint8_t mode)
{
  this->_mode = mode;
  if (_mode)
    this->_weatherCode = this->_currentWeatherCode;
  else
    this->_weatherCode = this->_todayWeatherCode;

#if WEATHER_ICON_CHOICE == 0
  switch (this->_weatherCode)
  {
    case 0:_pictureCode = t0; _pictureSize = sizeof(t0);break;
    case 1:_pictureCode = t1; _pictureSize = sizeof(t1);break;
    case 2:_pictureCode = t2; _pictureSize = sizeof(t2);break;
    case 3:_pictureCode = t3; _pictureSize = sizeof(t3);break;
    case 4:_pictureCode = t4; _pictureSize = sizeof(t4);break;
    case 5:_pictureCode = t5; _pictureSize = sizeof(t5);break;
    case 6:_pictureCode = t6; _pictureSize = sizeof(t6);break;
    case 7:_pictureCode = t7; _pictureSize = sizeof(t7);break;
    case 8:_pictureCode = t7; _pictureSize = sizeof(t7);break;
    case 21:_pictureCode = t7; _pictureSize = sizeof(t7);break;
    case 22:_pictureCode = t7; _pictureSize = sizeof(t7);break;
    case 9:_pictureCode = t9; _pictureSize = sizeof(t9);break;
    case 10:_pictureCode = t9; _pictureSize = sizeof(t9);break;
    case 23:_pictureCode = t9; _pictureSize = sizeof(t9);break;
    case 24:_pictureCode = t9; _pictureSize = sizeof(t9);break;
    case 11:_pictureCode = t11; _pictureSize = sizeof(t11);break;
    case 12:_pictureCode = t11; _pictureSize = sizeof(t11);break;
    case 25:_pictureCode = t11; _pictureSize = sizeof(t11);break;
    case 301:_pictureCode = t11; _pictureSize = sizeof(t11);break;
    case 13:_pictureCode = t13; _pictureSize = sizeof(t13);break;
    case 14:_pictureCode = t14; _pictureSize = sizeof(t14);break;
    case 15:_pictureCode = t15; _pictureSize = sizeof(t15);break;
    case 16:_pictureCode = t16; _pictureSize = sizeof(t16);break;
    case 17:_pictureCode = t16; _pictureSize = sizeof(t16);break;
    case 28:_pictureCode = t16; _pictureSize = sizeof(t16);break;
    case 302:_pictureCode = t16; _pictureSize = sizeof(t16);break;
    case 18:_pictureCode = t18; _pictureSize = sizeof(t18);break;
    case 19:_pictureCode = t19; _pictureSize = sizeof(t19);break;
    case 20:_pictureCode = t20; _pictureSize = sizeof(t20);break;
    case 29:_pictureCode = t29; _pictureSize = sizeof(t29);break;
    case 30:_pictureCode = t30; _pictureSize = sizeof(t30);break;
    case 31:_pictureCode = t31; _pictureSize = sizeof(t31);break;
    case 32:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 49:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 53:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 54:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 55:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 56:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 57:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    case 58:_pictureCode = t53; _pictureSize = sizeof(t53);break;
    default:_pictureCode = t99; _pictureSize = sizeof(t99);break;
  }
#elif WEATHER_ICON_CHOICE == 1
  switch (this->_weatherCode)
  {
    case 0:_pictureCode = w00; _pictureSize = sizeof(w00);break;
    case 1:_pictureCode = w01; _pictureSize = sizeof(w01);break;
    case 2:_pictureCode = w02; _pictureSize = sizeof(w02);break;
    case 3:_pictureCode = w03; _pictureSize = sizeof(w03);break;
    case 4:_pictureCode = w04; _pictureSize = sizeof(w04);break;
    case 5:_pictureCode = w05; _pictureSize = sizeof(w05);break;
    case 6:_pictureCode = w06; _pictureSize = sizeof(w06);break;
    case 7:_pictureCode = w07; _pictureSize = sizeof(w07);break;
    case 8:_pictureCode = w08; _pictureSize = sizeof(w08);break;
    case 9:_pictureCode = w09; _pictureSize = sizeof(w09);break;
    case 10:_pictureCode = w10; _pictureSize = sizeof(w10);break;
    case 11:_pictureCode = w11; _pictureSize = sizeof(w11);break;
    case 12:_pictureCode = w12; _pictureSize = sizeof(w12);break;
    case 13:_pictureCode = w13; _pictureSize = sizeof(w13);break;
    case 14:_pictureCode = w14; _pictureSize = sizeof(w14);break;
    case 15:_pictureCode = w15; _pictureSize = sizeof(w15);break;
    case 16:_pictureCode = w16; _pictureSize = sizeof(w16);break;
    case 17:_pictureCode = w17; _pictureSize = sizeof(w17);break;
    case 18:_pictureCode = w18; _pictureSize = sizeof(w18);break;
    case 19:_pictureCode = w19; _pictureSize = sizeof(w19);break;
    case 20:_pictureCode = w20; _pictureSize = sizeof(w20);break;
    case 21:_pictureCode = w08; _pictureSize = sizeof(w08);break;
    case 22:_pictureCode = w09; _pictureSize = sizeof(w09);break;
    case 23:_pictureCode = w10; _pictureSize = sizeof(w10);break;
    case 24:_pictureCode = w11; _pictureSize = sizeof(w11);break;
    case 25:_pictureCode = w12; _pictureSize = sizeof(w12);break;
    case 26:_pictureCode = w15; _pictureSize = sizeof(w15);break;
    case 27:_pictureCode = w16; _pictureSize = sizeof(w16);break;
    case 28:_pictureCode = w17; _pictureSize = sizeof(w17);break;
    case 29:_pictureCode = w29; _pictureSize = sizeof(w29);break;
    case 30:_pictureCode = w30; _pictureSize = sizeof(w30);break;
    case 31:_pictureCode = w31; _pictureSize = sizeof(w31);break;
    case 32:_pictureCode = w18; _pictureSize = sizeof(w18);break;
    case 49:_pictureCode = w18; _pictureSize = sizeof(w18);break;
    case 53:_pictureCode = w53; _pictureSize = sizeof(w53);break;
    case 54:_pictureCode = w54; _pictureSize = sizeof(w54);break;
    case 55:_pictureCode = w55; _pictureSize = sizeof(w55);break;
    case 56:_pictureCode = w56; _pictureSize = sizeof(w56);break;
    case 57:_pictureCode = w18; _pictureSize = sizeof(w18);break;
    case 58:_pictureCode = w18; _pictureSize = sizeof(w18);break;

    case 301:_pictureCode = w08; _pictureSize = sizeof(w08);break;
    case 302:_pictureCode = w15; _pictureSize = sizeof(w15);break;
    default:_pictureCode = w99; _pictureSize = sizeof(w99);break;
  }
#endif
  *weatherCode = this->_pictureCode;
  *weatherSize = this->_pictureSize;
}

uint8_t WeatherNum::getMode()
{
  return this->_mode;
}

void WeatherNum::switchMode()
{
  _mode = !_mode;
}
